Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gccrs: Fix bad recursive operator overload call #3214

Merged
merged 1 commit into from
Oct 25, 2024
Merged

gccrs: Fix bad recursive operator overload call #3214

merged 1 commit into from
Oct 25, 2024

Conversation

philberty
Copy link
Member

@philberty philberty commented Oct 24, 2024

When we are typechecking the impl block for DerefMut for &mut T the implementation follows the usual operator overload check but this ended up just resolving directly to the Trait definition which ends up being recursive which we usually handle. The issue we had is that a dereference call can be for either the DEREF or DEREF_MUT lang item here it was looking for a recurisve call to the DEREF lang item but we were in the DEREF_MUT lang item so this case was not accounted for.

Fixes #3032

gcc/rust/ChangeLog:

* typecheck/rust-hir-trait-reference.h: new get locus helper
* typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::get_locus): implemention
* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_operator_overload): fix overload

gcc/testsuite/ChangeLog:

* rust/compile/nr2/exclude:
* rust/compile/issue-3032-1.rs: New test.
* rust/compile/issue-3032-2.rs: New test.

When we are typechecking the impl block for DerefMut for &mut T
the implementation follows the usual operator overload check
but this ended up just resolving directly to the Trait definition
which ends up being recursive which we usually handle. The issue
we had is that a dereference call can be for either the DEREF
or DEREF_MUT lang item here it was looking for a recurisve call
to the DEREF lang item but we were in the DEREF_MUT lang item
so this case was not accounted for.

Fixes #3032

gcc/rust/ChangeLog:

	* typecheck/rust-hir-trait-reference.h: new get locus helper
	* typecheck/rust-hir-trait-resolve.cc (AssociatedImplTrait::get_locus): implemention
	* typecheck/rust-hir-type-check-expr.cc (TypeCheckExpr::resolve_operator_overload):
	fix overload

gcc/testsuite/ChangeLog:

	* rust/compile/nr2/exclude: nr2 cant handle this
	* rust/compile/issue-3032-1.rs: New test.
	* rust/compile/issue-3032-2.rs: New test.

Signed-off-by: Philip Herron <[email protected]>
@philberty philberty added this pull request to the merge queue Oct 25, 2024
Merged via the queue into master with commit 8f23349 Oct 25, 2024
12 checks passed
@philberty philberty deleted the phil/dev branch November 1, 2024 16:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Deref and DerefMut cause ambiguity issues when resolving
2 participants